<template>
  <el-dialog
    title="修改信息"
    :visible.sync="updateInfo"
    width="30%"
    :close-on-click-modal="false"
  >
    <el-form :model="form">
      <el-form-item label="名称">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    
    <span slot="footer" class="dialog-footer">
      <el-button @click.stop="updateInfo = false">取 消</el-button>
      <el-button type="primary" @click.stop="handleClick">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { addApplication } from '@/api/design'
export default {
  data(){
    return{
      updateInfo:false,
      form:{name:''},
      id:''
    }
  },
  methods:{
    init(apps){
      this.id = apps.id
      this.form.name = apps.appName
      this.updateInfo = true
    },
    handleClick(){
      addApplication({id:this.id,appName:this.form.name}).then(res=>{
        if(res.code === 200){
          this.$message.success('修改成功')
          this.updateInfo = false
          this.$store.dispatch('application/getAllApp')
        }else{
          this.$message.error('修改失败')
        }
      }).catch(_=>this.$message.error('修改失败'))



    }
  }
}
</script>

<style>

</style>